package com.snopy.stream;

import lombok.extern.slf4j.Slf4j;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

/**
 * @author snopy
 * @version 1.0.0
 * @classname CopyCharacters
 * @description
 * @email 77912204@qq.com
 * @date 2022/07/29 15:24
 */
@Slf4j
public class CopyCharacters {
    public static void main(String[] args) {
        FileReader inputStream = null;
        FileWriter outStream = null;
        try {
            inputStream = new FileReader("Sonata_java8/src/main/resources/xanadu.txt");
            outStream = new FileWriter("Sonata_java8/src/main/resources/characteroutput.txt");
            int c;
            while ((c=inputStream.read())!=-1){
                outStream.write(c);
            }

        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            if (inputStream!=null){
                try {
                    inputStream.close();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            if (outStream!=null){
                try {
                    outStream.close();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
}
